#!usr/bin/env python  
# -*- coding:utf-8 -*-
""" 
@author:'手机视界' 
@file: views.py 
@time: 2018/12/18
"""
import os
import logging

from django.shortcuts import render_to_response
from django.conf import settings

LOG = logging.getLogger(__name__)


def page_not_found(request, *args, **kwargs):
    root_templates = os.listdir(settings.ROOT_DIR)
    request_path = request.path[1:]
    LOG.warning("根目录文件:%s,请求文件:%s" % (root_templates, request_path))
    if request_path in root_templates:
        return render_to_response(request_path)
    return render_to_response('error/404.html')


def page_error(request, *args, **kwargs):
    return render_to_response('error/500.html')


def permission_denied(request, *args, **kwargs):
    return render_to_response('error/403.html')
